package com.rw.tool.util.expression.exception;

import com.rw.tool.util.expression.element.ExpressionElement;
import com.rw.tool.util.expression.state.InfixExpressionState;

import java.util.List;

/**
 * 校验中缀表达式异常
 */
public class CheckInfixExpressionException extends InfixExpressionException {
    private final InfixExpressionState state;

    private final List<ExpressionElement> elements;

    private final int index;

    public CheckInfixExpressionException(InfixExpressionState state, List<ExpressionElement> elements, int index) {
        super(getErrorMessage(state, index));
        this.state = state;
        this.elements = elements;
        this.index = index;
    }

    /**
     * 获取当前状态
     */
    public InfixExpressionState getState() {
        return state;
    }

    /**
     * 获取元素列表
     */
    public List<ExpressionElement> getElements() {
        return elements;
    }

    /**
     * 获取当前的元素位置
     */
    public int getIndex() {
        return index;
    }
}
